#include <QFile>
#include <QApplication>
#include <QtGui>
#include <QtCore> 
#include <QTextCodec>
#include <QCoreApplication>
#include <QApplication>
#include <QtGui>
#include "main.h"
#include "dav_main.h"
#include <QTranslator>



static inline QString UserLanguage()
{
     /////////////QSettings setter;
     QString languser,languagesistem,langqt; 
	QLocale loci = QLocale::system();
             languser = getenv("LANG");
             languser = languser.toLower();
             languagesistem = loci.name();
             languagesistem = languagesistem.toLower();
	     languagesistem = languagesistem.left(2);
     /* Window XP Prof MUI Multiuser == stay only "c" language && user setting setenv !!! */
     if (languagesistem == "c") { 
         if (languser.size() > 2 && languser.contains("_")) {
             languagesistem = languser.left(2);
         }
     }
  return languagesistem;
}








int main(int argc, char *argv[]) {
     QApplication a( argc, argv );
    
        QCoreApplication::setOrganizationName(_ORGANIZATION_NAME_);
        QCoreApplication::setOrganizationDomain(_PROGRAM_NAME_DOMAINE_);
        QCoreApplication::setApplicationName(_PROGRAM_NAME_);
    

    
       QString localedirfile = QString("%1/locale/webdav_%2.qm").arg(QDir::currentPath()).arg(UserLanguage()); 
       qDebug() << "#### localedirfile ->" << localedirfile;
       QTranslator translator;
       translator.load(localedirfile);
       a.installTranslator(&translator);
    
    
    
    
       
       Dav_Main::self()->setWindowTitle( _PROGRAM_TITLE_ );
	   Dav_Main::self()->show();
     a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    return a.exec();
}







       /*

    QSettings setter;
       QString language =  QString(setter.value("speaker").toString());
       if (language.size() > 1) {



      bool ok;
       QStringList items;
       items << "en" << "it" << "fr" << "de";
       
       if (language.size() < 1) {
           QString setlang = QInputDialog::getItem(0,"Select one Language","Short name:", items, 0, false, &ok);
           if (ok && !setlang.isEmpty()) {
           setter.setValue("speaker",setlang);
            language = setlang;
           }
       }
    
       qDebug() << "#### language ->" << language;
    */
    
    
    
